﻿<Window x:Class="Writespace.Dialogs.TextEditorWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:props="clr-namespace:Writespace.Dialogs.Properties"
        Title="Writespace"
        Height="338"
        Width="744"
        Background="{Binding Source={x:Static props:Settings.Default}, Path=BackgroundColor}"
        Loaded="Window_Loaded"
        Margin="0"
        WindowStyle="None"
        ResizeMode="NoResize">

    <Window.Resources>
        <props:Settings x:Key="Settings" />
    </Window.Resources>

    <Grid  IsSharedSizeScope="True">
       
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="Column1"
                              Width="{Binding Path=Default.Margin}"
                              MinWidth="50"
                              SharedSizeGroup="ColWidth" />
            <ColumnDefinition x:Name="Column2"
                              MinWidth="50" />
            <ColumnDefinition x:Name="Column3"
                              SharedSizeGroup="ColWidth" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition x:Name="TopRow"
                           Height="{Binding Path=Default.Margin}" />
            <RowDefinition x:Name="MainRow"
                           Height="*" />
            <RowDefinition x:Name="InfoRow"
                           Height="25" />
        </Grid.RowDefinitions>

        <GridSplitter x:Name="Splitter"
                      Grid.Column="0"
                      Grid.Row="0"
                      Grid.RowSpan="3"
                      Width="5"
                      Background="Transparent"
                      DragCompleted="Splitter_DragCompleted"
                      MouseEnter="Splitter_MouseEnter"
                      MouseLeave="Splitter_MouseLeave" />

        <Canvas Grid.Column="0"
                Grid.Row="2"
                Panel.ZIndex="11">
            <Label x:Name="StatusLabel"
                   Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                   Content="Status"
                   Margin="15,0,0,0"
                   FontFamily="Courier New"
                   Height="25"
                   Width="Auto" />
        </Canvas>

        <Label x:Name="RowCol"
               Grid.Column="1"
               Grid.ColumnSpan="2"
               Grid.Row="2"
               Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
               Content="Ln 20 Col 12"
               Margin="50,0,0,0"
               FontFamily="Courier New">
            <Label.Triggers>
                <EventTrigger RoutedEvent="Label.MouseEnter">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="RowCol"
                                            Storyboard.TargetProperty="(Label.Foreground).Color"
                                            To="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                                            Duration="0:0:0.5" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger RoutedEvent="Label.MouseLeave">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="RowCol"
                                            Storyboard.TargetProperty="(Label.Foreground).Color"
                                            To="Transparent"
                                            Duration="0:0:1" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Label.Triggers>
        </Label>

        <TextBox Grid.Column="1"
                 Grid.Row="1"
                 Name="MyTextBox"
                 Language="{Binding Path=Default.Langugae}"
                 SpellCheck.SpellingReform="PreAndPostreform"
                 CaretBrush="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                 SpellCheck.IsEnabled="True"
                 TextWrapping="Wrap"
                 Background="Transparent"
                 Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                 Margin="0"
                 FontFamily="{Binding Source={x:Static props:Settings.Default}, Path=FontFamily}"
                 AcceptsReturn="True"
                 TextDecorations="None"
                 AcceptsTab="True"
                 FontSize="{Binding Source={x:Static props:Settings.Default}, Path=FontSize}"
                 PreviewMouseWheel="MyTextBox_PreviewMouseWheel"
                 KeyUp="MyTextBox_KeyUp"
                 KeyDown="MyTextBox_KeyDown"
                 PreviewKeyDown="MyTextBox_PreviewKeyDown"
                 PreviewKeyUp="MyTextBox_KeyUp"
                 PreviewMouseDown="MyTextBox_MouseDown"
                 BorderThickness="0"
                 Padding="0"
                 GotFocus="MyTextBox_GotFocus" />

        <Canvas  Visibility="Hidden"
                 x:Name="SearchPanel"
                 Panel.ZIndex="11"
                 Margin="50,50,0,0">
            <Border BorderThickness="3"
                    Margin="2"
                    CornerRadius="5"
                    BorderBrush="{Binding Source={x:Static props:Settings.Default}, Path=Color}">
                <StackPanel Orientation="Horizontal"
                            Height="50"
                            Width="300">
                    <Label Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                           FontSize="16"
                           Content="Find what:"
                           Margin="10" />
                    <TextBox x:Name="SearchBox"
                             FontSize="16"
                             Width="100"
                             KeyDown="SearchBox_KeyDown"
                             Margin="10" />
                    <Button  FontSize="16"
                             Content="Find"
                             Background="Transparent"
                             BorderBrush="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                             Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                             Click="SearchButton_Click"
                             Margin="10" />

                </StackPanel>
                <Border.BitmapEffect>
                    <DropShadowBitmapEffect ShadowDepth="10"
                                            Color="{Binding Source={x:Static props:Settings.Default}, Path=Color}" />
                </Border.BitmapEffect>
            </Border>
        </Canvas>

        <Canvas  Visibility="Hidden"
                 x:Name="GotoPanel"
                 Panel.ZIndex="11"
                 Margin="50,100,0,0">
            <Border BorderThickness="3"
                    Margin="2"
                    CornerRadius="5"
                    BorderBrush="{Binding Source={x:Static props:Settings.Default}, Path=Color}">
                <StackPanel Orientation="Horizontal"
                            Height="50"
                            Width="300">
                    <Label Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                           FontSize="16"
                           Content="Go to line:"
                           Margin="10" />
                    <TextBox x:Name="GotoBox"
                             FontSize="16"
                             Width="100"
                             KeyDown="GotoBox_KeyDown"
                             Margin="10" />
                    <Button  FontSize="16"
                             Background="Transparent"
                             BorderBrush="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                             Foreground="{Binding Source={x:Static props:Settings.Default}, Path=Color}"
                             Content="Goto"
                             Click="GotoButton_Click"
                             Margin="10" />

                </StackPanel>
                <Border.BitmapEffect>
                    <DropShadowBitmapEffect ShadowDepth="10"
                                            Color="{Binding Source={x:Static props:Settings.Default}, Path=Color}" />
                </Border.BitmapEffect>
            </Border>
        </Canvas>

    </Grid>

</Window>
